<?php


namespace app\index\controller;


use app\BaseController;
use app\index\business\sourceBus;
use think\facade\View;

class Source extends BaseController
{
    public function index(){
        View::assign("title",'实时货源');
        return View::fetch();
    }
    public function getSourceListPage(){
        $where = $this->request->param('where');
        $where['status'] = 2;
        $paging = $this->request->param('paging');
        $whereTime = $this->request->param('whereTime');
        $title = $this->request->param('title');
        $consignorBus = new sourceBus();
        try {
            $res = $consignorBus->getAllListPage($where,$paging,$whereTime,$title);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }
        return show(config('status.success'),'查询成功',$res);
    }
    public function detail(){
        $id = $this->request->param('id');
        View::assign('id',$id);
        View::assign("title",'实时货源详情');
        return View::fetch();
    }
    public function getDetail(){
        $id = $this->request->param('id');
        $consignorBus = new sourceBus();
        try {
            $res = $consignorBus->getDetailBus($id);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }

        return show(config('status.success'),'查询成功',$res);
    }
    public function applyConsignorItem(){
        $consignor_item_id = $this->request->param('consignor_item_id');
        $member_id = $this->request->param('member_id');
        $consignorBus = new sourceBus();
        try {
            $res = $consignorBus->applyConsignorItemBus($consignor_item_id,$member_id);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }
        return show(config('status.success'),'申请成功，等待审核',$res);
    }

    public function isApplyAdd(){
        $consignor_item_id = $this->request->param('consignor_item_id');
        $member_id = $this->request->param('member_id');
        $consignorBus = new sourceBus();
        try {
            $res = $consignorBus->isApplyAddBus($consignor_item_id,$member_id);
        } catch (\Exception $exception){
            return show(config('status.error'),$exception->getMessage());
        }
        return show(config('status.success'),'查看成功',$res);
    }
}